// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import Vuex from 'vuex'
import './config/index'


import ElementUI from 'element-ui'
import 'element-ui/lib/theme-default/index.css'
import '../static/style/admin.css'

Vue.use(ElementUI)
Vue.use(Vuex)

Vue.config.productionTip = false


const store=new Vuex.Store({
	state:{
		token:null,
		login:false,
		allLoad:false,
	},
	mutations:{
		//获取token
		token(state,value){
			state.token=value
			state.login=true
		},
		//重新登录
		loginTo(state){
			state.login=false
		},
		//提交信息
		loadOpen(state,value){
			state.allLoad=true
		},
		//提交完成
		loadClose(state,value){
			state.allLoad=false
		}
	},
	actions:{
		//保存token
		tokensync({dispatch,commit},value){
			return commit('token',value);
		},
		//重新登录
		tokensyncTo({dispatch,commit},value){
			return commit('tokenTo',value);
		},
		//提交信息
		loadOpen({dispatch,commit},value){
			return commit('loadOpen',value);
		},
		//提交完成
		loadClose({dispatch,commit},value){
			return commit('loadClose',value);
		}
	}
})

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  template: '<App/>',
  components: { App }
})
